package cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.service;

import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.entity.Employee;
import cn.edu.sdjzu.xg.eagle.xg23_kcsj_01.mapper.EmployeeMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmployeeService {
    @Autowired
    private EmployeeMapper employeesMapper;
    public PageInfo<Employee> get(int pageNum,int pageSize,Employee employee){
        PageHelper.startPage(pageNum,pageSize);
        List<Employee> employeesList  = employeesMapper.get(employee);
        return PageInfo.of(employeesList);
    }
    public String save(Employee employee){
        if(employeesMapper.save(employee)){
            return "保存成功";
        }
        return "保存失败";
    }
    public String update(Employee employee){
        if(employeesMapper.update(employee)){
            return "修改成功";
        }
        return "修改失败";
    }
    public String delete(int id){
        if(employeesMapper.delete(id)){
            return "删除成功";
        }
        return "删除失败";
    }
}
